import pytest

from Util.DBUtil import DBUtil


@pytest.fixture(scope='class')
def prepareActorData():
    connObj,cursor = DBUtil.openDB()
    sqlList = {
        "insert into tb_actor (actor_name,actor_img,actor_desc,followers,box_office) " \
        "values ('worldwind_actor1',null,'young man',0,0)",
        "insert into tb_actor (actor_name,actor_img,actor_desc,followers,box_office) " \
        "values ('worldwind_actor2',null,'old man',0,0)",
        "insert into tb_actor (actor_name,actor_img,actor_desc,followers,box_office) " \
        "values ('worldwind_actor3',null,'super man',0,0)"
    }
    for sql in sqlList:
        DBUtil.writeDB(sql,cursor)
    connObj.commit()
    yield
    delsql = "DELETE FROM tb_actor WHERE actor_name LIKE 'worldwind%'"
    DBUtil.writeDB(delsql,cursor)
    connObj.commit()
    DBUtil.release(cursor,connObj)
